#include "includes/universal.h"
#include "includes/graphFunc.h"
#include "includes/util.h"
#include "includes/game.h"

// UI线程
void *UI_ThreadMethod(void *input) {
    // 初始化SDL
    int initRet = SDL_Init(SDL_INIT_EVERYTHING);
    MyWindow *gameWindow = (MyWindow *) input;
    if (initRet == -1) {
        outputDebug(ERROR_CODE, "初始化SDL失败");
    } else {
        outputDebug(INFO_CODE, "初始化SDL成功");
        outputDebug(INFO_CODE, "创建游戏窗口");
        // 创建游戏窗口
        gameWindow = createGameWindow(gameWindow);
        // 绘制菜单栏
        winLoop(gameWindow);
    }
    gameWindow = nullptr;
    return nullptr;
}

// 游戏逻辑线程
void *GAME_ThreadMethod(void *input) {

}

// 背景音乐线程
void *MUSIC_ThreadMethod(void *input) {

}

// 创建游戏窗口
static MyWindow *createGameWindow(MyWindow *gameWindow) {
    if (gameWindow == nullptr) {
        outputDebug(WARN_CODE, "空指针，创建游戏窗口对象");
        gameWindow = newMyWinP(1);
    }
    gameWindow->shouldClose = false;
    gameWindow->isInited = true;
    gameWindow->width = WINDOW_WIDTH;
    gameWindow->height = WINDOW_HEIGHT;
    gameWindow = winCoreInit(gameWindow);
    return gameWindow;
}

static MyWindow *renderGameMenu(MyWindow *gameWindow) {



}